package com.hyj.ecp.backstage.cust.action;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.ecp.cust.ClientUserQO;
import com.ecp.goods.GoodsQO;
import com.ecp.goods.GoodsTrait;
import com.hyj.ecp.backstage.cust.service.ICustService;
import com.hyj.ecp.backstage.sys.bean.vo.User;

@Controller
@SessionAttributes("user")
@RequestMapping("/backstage/cust/*")
public class CustAction {
	Log log = LogFactory.getLog(CustAction.class);
	@Autowired
    private ICustService service;
	
	
	@RequestMapping(value="queryClientUser.do")
    public String queryClientUser(ClientUserQO qo,ModelMap map)
    {
    	log.info("queryClientUser.do  start...");
    	map.put("list", new Object[]{});
    	return "view/backstage/cust/querycust";
    }
	
	@ResponseBody
	@RequestMapping(value="queryUser.do")
    public Object queryUser(HttpServletRequest request,ClientUserQO qo)
    {
    	log.info("queryClientUser.do  start...");

    	Map<String,Object> vo = service.queryClientUsers(qo);
    	return vo;
    }
	
	
	  /**
     * 客户信息查看
     * @param qo1
     * @param map
     * @return
     * @throws IOException
     */
    @RequestMapping(value="toViewcust.do")
    public String toViewcust(ClientUserQO qo1,ModelMap map) throws IOException
    {
    	log.info("toViewcust.do");
    	User u =  (User)map.get("user");
    	if(u==null){
    		return "view/common/noLogin";// 没有登入 直接到登入界面 
    	}
    	qo1.setCurPage(-1);//不要分页查询
    	 Map<String, Object> user  = service.toViewcust(qo1);
    	if(user!=null){
    	   map.put("vo", user);
    	} 
    	
		return "view/backstage/cust/custInfo";
    }
	
	//queryCustProblem.jsp
	@RequestMapping(value="toqueryCustProblem.do")
    public String toQueryCustProblem(ClientUserQO qo)
    {
    	log.info("toqueryCustProblem.do  start...");
    	return "view/backstage/cust/queryCustProblem";
    }
	
	
	@ResponseBody
	@RequestMapping(value="queryCustCustProblem.do")
    public Object queryCustCustProblem(HttpServletRequest request,ClientUserQO qo)
    {
    	log.info("queryCustCustProblem.do  start...");

    	Map<String,Object> vo = service.queryCustCustProblem(qo);
    	return vo;
    }
}
